import React, { useState, useEffect } from 'react';
import { Spin } from 'antd';
import { TRDefault } from '@/components/index.js';
import type { IFormValue } from '../type';
import styles from './index.less';

interface IProps {
  /**
   * 请求数据
   */
  formValue?: IFormValue;
  /**
   * 是否需要重新刷新数据
   */
  activeKey?: number;
}

const DeviationAnalysis = (props: IProps) => {
  const { formValue, activeKey } = props;
  const [loading, setLoading] = useState<boolean>(true);
  const [error, setError] = useState<boolean>(false);
  const [data, setData] = useState<any>();

  useEffect(() => {
    if (formValue?.calendarDate && formValue.provinceId && formValue.stationId) {
      setLoading(true);
      setError(false);
      setData({});
    }
  }, [activeKey]);

  return (
    <div className={styles.container}>
      {loading ? (
        <Spin />
      ) : error ? (
        <TRDefault type={'error'} message={'系统异常'} />
      ) : data ? (
        <div className={styles.main}>{''}</div>
      ) : (
        <TRDefault type={'emptysm'} message={'暂无数据'} />
      )}
    </div>
  );
};

export default DeviationAnalysis;
